package com.zp.filter;/**
 * @description
 * @author zp
 * @created 2021/9/3 20:58
 */

import java.util.ArrayList;
import java.util.List;

/**
 * @author zp
 * @description
 * @created 2021/9/3 20:58
 */
public class FilterPatternDemo {
    public static void main(String[] args) {
        List<Person> people = new ArrayList<Person>();
        Person person = new Person(0,"赵1");
        people.add(person);
        person = new Person(0,"刘2");
        people.add(person);
        person = new Person(0,"张3");
        people.add(person);
        person = new Person(1,"丽丽");
        people.add(person);
        person = new Person(1,"美美");
        people.add(person);
        person = new Person(1,"欣欣");
        people.add(person);
        FemaleCriteria femaleCriteria = new FemaleCriteria();
        List<Person> femalePeople = femaleCriteria.meetCriteria(people);
        System.out.println("开始遍历女性集合：");
        printPeople(femalePeople);
        MaleCriteria maleCriteria = new MaleCriteria();
        List<Person> malePeople = maleCriteria.meetCriteria(people);
        System.out.println("开始遍历男性集合：");
        printPeople(femalePeople);
    }

    static void printPeople(List<Person> people){
        for(Person person:people){
            System.out.println("姓名："+person.getName()+",性别："+(person.getGender()==0?"男":"女"));
        }
    }
}
